//Author: Soeren Pirk
//Date  : 11.04.2013

#include "Common.h"
#include "VertexBufferObjectAttribs.h"
#include "TgaLoader.h"
#include "Texture.h"

float frand(float low, float high)
{
    float result = (rand() / (static_cast<double>(RAND_MAX) + 1.0)) * (high - low) + low;
    return result;
}

void checkOpenGL()
{
    char *vendor = NULL;
    char *renderer = NULL;
    char *version = NULL;
    char *extentions = NULL;

    vendor = (char*)glGetString(GL_VENDOR);
    renderer = (char*)glGetString(GL_RENDERER);
    version = (char*)glGetString(GL_VERSION);
    extentions = (char*)glGetString(GL_EXTENSIONS);

    printf("Vendor: %s\n", vendor);
    printf("Renderer: %s\n", renderer);
    printf("Version: %s\n", version);
}

vec3 getCamPosFromModelView(const Transform &trans)
{
    mat4 m = trans.view;
    vec3 c;

    c.x = -(m.a11 * m.a43 + m.a21 * m.a24 + m.a31 * m.a34);
    c.y = -(m.a12 * m.a43 + m.a22 * m.a24 + m.a32 * m.a34);
    c.z = -(m.a13 * m.a43 + m.a23 * m.a24 + m.a33 * m.a34);

    return c;
}